﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LifeGame2.Models; 

public abstract class LifeGameCore {
    public bool[,] Pre;
    public bool[,] Curr;
    public int Width { get; }
    public int Height { get; }
    private bool _init;

    public abstract void Seeding(List<int[]> seeds);
    // line/100 的几率，是一个活细胞
    public abstract void RandomSeeding(int line);

    // Rules:
    // 1. A live cell will die when the live cells close to it are fewer than 2 (< 2);
    // 2. A live cell will die when the live cells close to it are more than 3 (> 3);
    // 3. A live cell will NOT die when the live cells close to it are equal to 3 (== 3);
    // 4. A DEAD cell will Revive when the live cells close to it are equal to 3 (== 3);
    private static readonly sbyte[] Dx = { 1, 1, 1, 0, -1, -1, -1, 0 };
    private static readonly sbyte[] Dy = { -1, 0, 1, 1, 1, 0, -1, -1 };
    private static readonly sbyte K8 = 8;
    public abstract bool[,] NextTurn();
}